<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class RM_Plugin_JoomlaSEF extends RM_Plugin implements RM_SEF_Manager_Interface
{
    /**
     * Public constructor
     */
    public function  __construct()
    {
        $this->name = 'JoomlaSEF';
    }

    public function getNode(){
        return null;
    }

    public function addLanguage($iso)
    {
        return true;
    }

    public function deleteLanguage($iso)
    {
        return true;
    }

    private function _getConfig()
    {
        $joomlaSEFObj = new RM_JoomlaSEF;
        $value = $joomlaSEFObj->getSettings()->toArray();
        return $value[0];
    }

    function getRouter() {
        $connector = RM_Environment::getConnector();
        if (strtolower(get_class($connector)) !== 'rm_joomla_connector') {
            return null;
        }
        
        $jconfig = new jconfig();
        $sefEnabled = (bool)$jconfig->sef;
        if ($sefEnabled == false) {
            return null;
        }

        $module = RM_Environment::getConnector()->getModule();

        $router = new RM_JoomlaSEF_Router($module);
        if ($module == 'admin') {
            $router->addRoute('default', new RM_JoomlaSEF_Router_Route_Admin(
                array(
                    'module' => $module,
                    'controller' => 'Index',
                    'action' => 'index',
                )
            ));
        } else {
            $router->addRoute('default', new RM_JoomlaSEF_Router_Route_User(
                array(
                    'module' => $module,
                    'controller' => 'Index',
                    'action' => 'index',
                )
            ));
        }

        return $router;
    }
}